#include "precompiled/pchkrayserkraw.h"
#include "kraw/KrawD3D9Material_Script.h"

#include "kraw/krawd3d9material.h"
#include "kraw/krawd3d9fixedmaterial.h"

#include "kernel/ncmdprotonativecpp.h"

nNebulaScriptClass( KrawD3D9Material_Script, "nroot" );

//-----------------------------------------------------------------------------

NSCRIPT_INITCMDS_BEGIN( KrawD3D9Material_Script )
    NSCRIPT_ADDCMD( 'BMAT', void, BeginMaterial, 2, (const char *, const char *), 0, () );
    NSCRIPT_ADDCMD( 'EMAT', void, EndMaterial, 0, (), 0, () );
NSCRIPT_INITCMDS_END()

//-----------------------------------------------------------------------------

KrawD3D9Material_Script::KrawD3D9Material_Script()
{
}

//-----------------------------------------------------------------------------

void KrawD3D9Material_Script::BeginMaterial( const char* type, const char* path )
{
    if ( !strcmp( type, "dx9" ) )
        this->material = n_new( KrawD3D9Material );
    else if ( !strcmp( type, "fixed" ) )
        this->material = n_new( KrawD3D9FixedMaterial );
    else
        this->material = 0;

    if ( this->material ) this->material->Register( path );
}

//-----------------------------------------------------------------------------

void KrawD3D9Material_Script::EndMaterial()
{
    this->material = 0;
}
